package com.controller;

import com.entity.Auction;
import com.service.AuctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class AuctionController {
    @Autowired
    private AuctionService auctionService;

    @RequestMapping("/selectAll")
    public String selectAll(Map map){
        List<Auction> list=auctionService.selectAll();
        map.put("list",list);
        return "main";
    }
    @RequestMapping("/insert")
    public String insert(Auction auction){
        auctionService.insert(auction);
        return "redirect:/selectAll.do";
    }
    @RequestMapping("/delete")
    public String delete(Integer auctionId){
        auctionService.delete(auctionId);
        return "redirect:/selectAll.do";
    }
    @RequestMapping("/update")
    public String update(Auction auction){
        auctionService.update(auction);
        return "redirect:/selectAll.do";
    }
    @RequestMapping("/selectById")
    public String selectById(Integer auctionId,Map map){
        Auction auction=auctionService.selectById(auctionId);
        map.put("auction",auction);
        return "update";
    }
}
